//use jquery easyui Datepicker
Tapestry.Initializer.DateFieldEx = function(spec) {
	var jq = jQuery;
	var input = jq("#" + spec.field);
	var trigger = jq("#" + spec.field + "-trigger");
	var datePicker = jq("#" + spec.field + "-calendar");
	datePicker.css('position', 'absolute');
	datePicker.hide();
	spec.width = 250;
	spec.height = 250;
	spec.onSelect = function(date) {
		var theYear = date.getFullYear();
		var theMonth = date.getMonth() + 1;
		var theDate = date.getDate();
		if (theMonth < 10) {
			theMonth = "0" + theMonth;
		}
		if (theDate < 10) {
			theDate = "0" + theDate;
		}
		input.val(theYear + "-" + theMonth + "-" + theDate);
		datePicker.hide();
	};
	spec.current = new Date(spec.date);
//	datePicker.mouseleave(function(){
//		datePicker.hide();
//	});
	datePicker.calendar(spec);
	trigger.click(function() {
		datePicker.toggle();
	});
};
